<?php

namespace DebugComponent\Plugin;

class PHPInfo implements \DebugComponent\IPlugin, \DebugComponent\IRenderable {

    public function setRenderer(\DebugComponent\IRenderer $renderer) {
        $this->renderer = $renderer;
    }

    public function getTitle() {
        return 'PHP';
    }

    public function getSubtitle() {
        return \phpversion();
    }

    public function render() {
        $data = new \DebugComponent\ParameterHolder();
        $extensions = \get_loaded_extensions();
        usort($extensions, 'strcasecmp');
        foreach ($extensions as $index=>$extension) {
            $extensions[$index] = array('name' => $extension, 'version' => \phpversion($extension));
        }
        $data->set('extensions', $extensions);
        $data->set('phpIniPath', \php_ini_loaded_file());
        $data->set('phpAdditionalIniPaths', \explode(',', \php_ini_scanned_files()));
        $data->set('uname', \php_uname());
        $data->set('phpVersion', \phpversion());
        $data->set('zendVersion', \zend_version());
        $data->set('temporaryDirectory', \sys_get_temp_dir());
        $data->set('title', $this->getTitle());
        $data->set('subtitle', $this->getSubtitle());
        return $this->renderer->render($data);
    }

    private $renderer;
}